package com.jsgt.greekfire.ui.mine.coindetail.recorddetail

import android.content.Context
import android.content.Intent
import android.view.View
import com.fhx.core.base.BaseActivity
import com.fhx.core.utils.DateFormatUtil
import com.jsgt.greekfire.R
import com.jsgt.greekfire.bean.BillBean
import com.jsgt.greekfire.ui.mine.coindetail.recharge.rechargerecord.RechargeRecordActivity
import kotlinx.android.synthetic.main.activity_record_detail.*

/**
 * 充币提币记录
 * author fhx
 * create time 2020/5/10 21:51
 **/
class RecordDetailActivity : BaseActivity() {
    private var typeStr = "USDT"

    override fun getLayoutId(): Int = R.layout.activity_record_detail

    companion object {
        private const val RECORD_BEAN = "bean"
        private const val TYPE = "type"
        const val RECHARGE = 0
        const val WITHDRAW = 1

        private const val ASSET_TYPE = "assetType"
        const val GFC = 1
        const val USDT = 2
        const val GFT = 3

        fun start(context: Context, type: Int, bean: BillBean) {
            val intent = Intent(context, RecordDetailActivity::class.java)
            intent.putExtra(RECORD_BEAN, bean)
            intent.putExtra(TYPE, type)
            context.startActivity(intent)
        }

        fun start(context: Context, type: Int, bean: BillBean, assetTypeId: Int) {
            val intent = Intent(context, RecordDetailActivity::class.java)
            intent.putExtra(RECORD_BEAN, bean)
            intent.putExtra(TYPE, type)
            intent.putExtra(ASSET_TYPE, assetTypeId)
            context.startActivity(intent)
        }
    }

    override fun main() {
        title = ""
        val billBean = intent.getParcelableExtra<BillBean>(RECORD_BEAN)
        val type = intent.getIntExtra(TYPE, 0)
        var assetTypeId = intent.getIntExtra(ASSET_TYPE, 2)
        if(assetTypeId == 3){
            typeStr = "GFT"
        }

        if (type == RECHARGE) {
            type_tv.text = "普通充币"
            charge_name_tv.text = "区块链交易ID"
            price_tv.text = "+${billBean.assetAmt} USDT"
            charge_tv.text = billBean.remark
            date_tv.text = DateFormatUtil.formatNew(billBean.createTime, "MM月dd日 HH:mm")
        } else {
            type_tv.text = "普通提币"
            price_tv.text = "-${billBean.money} $typeStr"
            address_tv.text = billBean.address
            address_layout.visibility = View.VISIBLE
            charge_tv.text = billBean.serviceFee + "$typeStr"
            date_tv.text = DateFormatUtil.formatNew(billBean.updatedAt, "MM月dd日 HH:mm")
            when (billBean.status) {
                1 -> status_tv.text = "已提交"
                2 -> status_tv.text = "已完成"
                3 -> status_tv.text = "已拒绝"
            }
        }
    }
}